package net.bolue.web.mvc;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import net.bolue.console.model.UpdateModel;
import net.bolue.sysmng.exception.BolueException;
import net.bolue.sysmng.model.UpdResModel;
import net.bolue.sysmng.tblbean.UpdRes;
import net.bolue.web.report.RepConstants;
import net.bolue.web.util.RequestUtil;

public class UpdateAction extends AbstractAction{

	@Override
	public ActionResult perform(HttpServletRequest request, HttpServletResponse response) throws BolueException{
		String subSys = RequestUtil.getParamValue(request, RepConstants.REP_SUBSYS_KEY);
		String updateId = RequestUtil.getParamValue(request, RepConstants.REP_UPDATEID_KEY);
		if(subSys==null || subSys.trim().length()==0 || updateId==null || updateId.trim().length()==0){
			throw new BolueException(1, "修改URL中必须提供subSys及updateID参数值!");
		}
		UpdResModel updResModel = new UpdResModel(request);
		UpdRes updRes = updResModel.getUpdRes(subSys, updateId);
		if(updRes==null){
			throw new BolueException(10, "没有找到subSys="+subSys+",updateID="+updateId+"的更新记录所用资源！");
		}
		
		UpdateModel updateModel = new UpdateModel(request,updRes);
		return updateModel.update();
	}
	
}
